﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SpringEngine
{
    public class Spring
    {
        public Pair<Endpoint, Endpoint> Endpoints { get; private set; }
        /// <summary>
        /// Length of normal spring position
        /// </summary>
        public double Length { get; set; }
        /// <summary>
        /// Best effects: (0, 2]. Value 1 is default
        /// </summary>
        public double Flexibility { get; set; }

        public Spring(ISpringable firstEndpoint, ISpringable secondEndpoint, double length, double flexibility = 1)
        {
            Endpoints = new Pair<Endpoint, Endpoint>
            {
                First = Endpoint.CreateEndpoint(firstEndpoint),
                Second = Endpoint.CreateEndpoint(secondEndpoint)
            };
            Length = length;
            Flexibility = flexibility;
        }

        public Spring(Endpoint firstEndpoint, Endpoint secondEndpoint, double length, double flexibility = 1)
        {
            Endpoints = new Pair<Endpoint, Endpoint>
            {
                First = firstEndpoint,
                Second = secondEndpoint
            };
            Length = length;
            Flexibility = flexibility;
        }
    }
}
